package com.miracle.blog.controller;


import com.miracle.blog.dto.BlogBackInfoDTO;
import com.miracle.blog.dto.BlogHomeInfoDTO;
import com.miracle.blog.service.BlogInfoService;
import com.miracle.blog.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 博客信息Controller
 *  */

@Api(tags = "博客信息模块")
@RestController
public class BlogInfoController {

    @Autowired
    private BlogInfoService blogInfoService;

    /**
     * 上传访客信息
     *
     * @return {@link Result}
     */
    @PostMapping("/report")
    public Result<?> report() {
        blogInfoService.report();
        return Result.ok();
    }


    @GetMapping("/admin")
    public Result<BlogBackInfoDTO> getBlogBackInfo(){
        return Result.ok(blogInfoService.getBlogBackInfo());
    }

    /**
     * 查看博客信息
     *
     * @return {@link Result<BlogHomeInfoDTO>} 博客信息
     */
    @ApiOperation(value = "查看博客信息")
    @GetMapping("/")
    public Result<BlogHomeInfoDTO> getBlogHomeInfo() {
        return Result.ok(blogInfoService.getBlogHomeInfo());
    }
}
